<cfparam name="organizationID" type="integer" default="0">

<cfset sites = application.siteGateway.getAllAsQuery("*", organizationID, "Site")>

<cfoutput>

	<p>
		<a href="#script_name#?view=createSite&rv=#view#&siteID=0&organizationID=#organizationID#" class="btn">New&nbsp;site</a>
		<span class="pull-right"><strong>Count:</strong> #sites.RecordCount#</span>
	</p>
	
	<cfif sites.RecordCount gt 0>
	
		<table id="sitesTable" width="100%" style="display: none">
			<thead>
				<tr>
					<th>ID</th>
					<th>Organization</th>
					<th>Name</th>
					<th>Site Type</th>
					<th>City</th>
					<th>County</th>
					<th>Region</th>
					<th>Internet Computers</th>
					<th>Workshops</th>
				</tr>
			</thead>
			<tbody>
				<cfloop query="sites">
					<tr>
						<td><a href="#script_name#?view=editSite&rv=#view#&siteID=#Site_ID#&organizationID=#Organization_ID#">#Site_ID#</a></td>
						<cfif NOT organizationApproved>
							<td><font color="red">#Organization#</font></td>
						<cfelse>
							<td>#Organization#</td>
						</cfif>
						<td>#Site#</td>
						<td>#Site_Type#</td>
						<td>#City#</td>
						<td>#County#</td>
						<td>#Region# (#Region_ID#)</td>
						<td>#Computers#</td>
						<td>#workshopCount#</td>
					</tr>
				</cfloop>
			</tbody>
		</table>
		
		<script type="text/javascript">
		$(function() {
			$("##sitesTable").kendoGrid({
				sortable: {
					mode: "single",
					allowUnsort: false
				},
				filterable: true,
				columnMenu: true				
			})
			$("##sitesTable").show();
		})
	</script>
	
	<cfelse>
	
		<div class="alert alert-info notFound">No sites</div>
		
	</cfif>

</cfoutput>